package com.good.child.ui.activity.ai;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.good.child.R;
import com.good.child.widgets.DotsProgress;
import com.yimidida.library.base.BaseActivity;
import com.yimidida.library.base.BasePresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * AI助手
 */
public class AiHelperActivity extends BaseActivity {
    @BindView(R.id.dot)
    DotsProgress dotsProgress;
    @BindView(R.id.im_voice)
    ImageView im_voice;
    @BindView(R.id.tv_status)
    TextView tv_status;
    @BindView(R.id.im_content)
    ImageView contentImage;
    boolean isOpen = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ai_helper);
        ButterKnife.bind(this);
        initView();
    }

    @Override
    protected BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected void initView() {
        setStatusBar(true, true, R.color.white);
        setLeftTv("", R.mipmap.ai_exit_icon, view -> finish());
        dotsProgress.startProgress();
        Glide.with(this)
                .asGif()
                .load(R.mipmap.icon_ai_dialogue)
                .into(contentImage);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (dotsProgress != null) {
            dotsProgress.endProgress();
        }
    }

    @OnClick({R.id.im_voice, R.id.im_hang_up})
    public void onClickView(View view) {
        switch (view.getId()) {
            case R.id.im_hang_up:
                finish();
                break;
            case R.id.im_voice:
                isOpen = !isOpen;
                im_voice.setImageResource(isOpen ? R.mipmap.icon_open_voice : R.mipmap.icon_close_voice);
                tv_status.setText(isOpen ? "你可以开始说话" : "你已静音");
                break;
        }
    }
}